
<?php
require_once '../model/db.php';
require_once '../config/config.php';
    $link="index.php";
    $total='SELECT COUNT(*) FROM works';
    $per_page=PAGES;
    var_dump($total);
    die();

function paging($total, $per_page, $link) { 
    
    $num_page = ceil ($total / $per_page); 
   
    if (!isset($_GET['page'])) $current_page = 1; 
    else $current_page = $_GET['page']; 

    // trang trước 
    if ($current_page > 1) { 
          echo '<a href="' . $link . '?page=' . ($current_page - 1) . '">Trang trước</a>'; 
    } 

    // các trang giữa 
    for ( $i = 1; $i < $total_page; $i++) { 
           echo '<a href="' . $link . '?page=' . $i . '">' . $i . '</a>'; 
    } 

    //trang sau 
    if ($current_page < $total_page) { 
          echo '<a href="' . $link . '?page=' . ($current_page + 1) . '">Trang sau</a>'; 
    } 
} 
?>

